package com.cwj.springboot_study.service.impl;

import com.cwj.springboot_study.model.Person;
import com.cwj.springboot_study.repositories.PersonRepository;
import com.cwj.springboot_study.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wujie.chen
 * 2023/3/23 18:49
 */
@Service
public class NoInterfaceTsTest {
    @Autowired
    private PersonRepository personRepository;
    @Autowired
    private PersonService personService;

    @Transactional
    public void test(){
        add();
        throw new RuntimeException();
    }

    public void test2(Person person){
        personService.add(person);
    }

    public void callSelf(){
        add();
    }

    @Transactional
    public void add(){
        Person person = new Person();
        person.setUsername("testlsl");
        person.setNickName("testlsl");
        person.setPassword("sdlsdld");
        personRepository.save(person);
        throw new RuntimeException();
    }
}
